
#include <QtCore/qstring.h>

#include "MainWindow.h"

#include <QtGui/QClipboard>

namespace jcrada {

    void MainWindow::setPso( ) {
//        getNeuralThread().getModel().setSize(getUiInspector().sbx_swarm_size->value());
//        int topology = getUiInspector().cbb_topology->currentIndex();
//        switch (topology) {
//            case 0: getNeuralThread().getModel().setTopology(aPsoModel::PT_RING);
//                break;
//            case 1: getNeuralThread().getModel().setTopology(aPsoModel::PT_STAR);
//                break;
//            case 2: getNeuralThread().getModel().setTopology(aPsoModel::PT_VON_NEUMANN);
//                break;
//            default:DEBUG(TO_STRING(topology));
//                assert(0);
//        }
//        int strategy = getUiInspector().cbb_velocity_cs->currentIndex();
//        switch (strategy) {
//            case 0: getNeuralThread().getModel().setVelocityClampingStrategy(aPsoModel::VCS_NONE);
//                break;
//            case 1: getNeuralThread().getModel().setVelocityClampingStrategy(aPsoModel::VCS_BASIC);
//                break;
//            case 2: getNeuralThread().getModel().setVelocityClampingStrategy(aPsoModel::VCS_TANH);
//                break;
//            default:DEBUG(TO_STRING(strategy));
//                assert(0);
//        }
//        strategy = getUiInspector().cbb_inertia_ws->currentIndex();
//        switch (strategy) {
//            case 0: getNeuralThread().getModel().setInertiaWeightStrategy(aPsoModel::IWS_NONE);
//                break;
//            case 1: getNeuralThread().getModel().setInertiaWeightStrategy(aPsoModel::IWS_LINEAR_DECREASING);
//                break;
//            case 2: getNeuralThread().getModel().setInertiaWeightStrategy(aPsoModel::IWS_NON_LINEAR_DECREASING);
//                break;
//            case 3: getNeuralThread().getModel().setInertiaWeightStrategy(aPsoModel::IWS_RELATIVE_IMPROVEMENT);
//                break;
//            default:DEBUG(TO_STRING(strategy));
//                assert(0);
//        }
//        getCreature().destroy();
//        getCreature().setHiddenLayers(getUiInspector().sbx_hidden_layers->value());
//        getCreature().setNeuronsPerLayer(getUiInspector().sbx_neurons_per_layer->value());
//        getCreature().create();
//        getNeuralThread().getModel().setCreature(getCreature());
//
//        getNeuralThread().setEpochs(getUiInspector().sbx_epochs->value());
//        getNeuralThread().getModel().setMaxEpochs(getUiInspector().sbx_epochs->value() *
//                getUiInspector().sbx_max_epochs->value() / 100.0);
//        getUiInspector().cbx_evaluation_time->setChecked(true);
//        getSimulatorThread().setEvaluationTimeInSeconds(getUiInspector().sbx_evaluation_time->value());
//        getNeuralThread().getModel().setParticleSize(getCreature().getNeuralNetwork()->getTotalNumberOfWeights() +
//                getCreature().getNeuralNetwork()->getTotalNumberOfNeurons());
//
//        getNeuralThread().getModel().setSimulator(&getSimulatorThread());
    }

    void MainWindow::resetPso( ) {
        pause();
//        getNeuralThread().getModel().destroy();
    }

    void MainWindow::psoFromClipboard( ) {

    }

    void MainWindow::psoToClipboard( ) {
//        QClipboard& clipboard = *QApplication::clipboard();
//        PsoNeuralModel& model =getNeuralThread().getModel();
//        QString xml;
//        for (int i = 0 ; i < model.getSize() ; ++i){
//            model.loadCreature(model.getParticle(i));
//            xml.append(QString(model.getCreature().toXml().c_str()));
//        }
//        DEBUG(xml.toStdString());
//        clipboard.setText(xml, QClipboard::Clipboard);
    }

}